<?php
/**
 * 切换到正式版
 */
namespace Core\Controller;
use Think\Controller;
use Common\Logic\ImLogic;
use Common\Util\Easemob;

header("content-type:application/json");
set_time_limit(0);

class ProController extends Controller 
{
    public function index()
    {
        die(0);
        $users = m('users')->field('user_id,password,nickname')->select();
        
        $result['user'] = [];

        foreach($users as $key => $v)
        {
            $result['user'][] = (new Easemob)->createUser($v['user_id'],$v['password'],$v['nickname']);
        }

        // $groups = ImLogic::

        echo json_encode($result);
        
    }

    // 统一修改用户名和手机号一致的用户
    public function mod()
    {
        die(0);
        $users = M('users')->field('user_id,mobile,nickname')->select();
        
        $result['user'] = [];

        foreach($users as $key => $v)
        {
            if( $v['mobile'] == $v['nickname'] )
            {
                $result['user'][] = M('users')->where([
                    'user_id' => $v['user_id']
                ])->save([
                    'nickname' => 'tsb_'.substr($v['mobile'],6)
                ]);
            }
        }
        echo json_encode($result);
    }
}